package com.example.droideep.fragment;

import android.app.Activity;
import android.os.Bundle;
import android.support.v4.app.ListFragment;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;

import com.example.droideep.R;
import com.example.droideep.common.dummydata.CalendarHolder;
import com.example.droideep.common.dummydata.CalendarHolder.CalendarItem;

import java.util.List;


/**
 * A fragment representing a list of Items.
 * <p/>
 * <p/>
 */
public class CalendarViewsFragment extends ListFragment {

    private final List<CalendarItem> calendarItems = CalendarHolder.ITEMS;

    /**
     * Mandatory empty constructor for the fragment manager to instantiate the
     * fragment (e.g. upon screen orientation changes).
     */
    public CalendarViewsFragment() {
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        // TODO: Change Adapter to display your content
        setListAdapter(new ArrayAdapter<CalendarItem>(getActivity(),
                android.R.layout.simple_list_item_1, android.R.id.text1, CalendarHolder.ITEMS));
    }


    @Override
    public void onAttach(Activity activity) {
        super.onAttach(activity);
    }

    @Override
    public void onDetach() {
        super.onDetach();
    }

    @Override
    public void onListItemClick(ListView l, View v, int position, long id) {
        super.onListItemClick(l, v, position, id);
        getFragmentManager()
                .beginTransaction()
                .replace(R.id.container, calendarItems.get(position).container)
                .addToBackStack(calendarItems.get(position).content)
                .commit();
    }

}
